﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Newtonsoft.Json;
using LiuYan.Entity;
using LiuYan.Service;
using LiuYan.Service;
using LiuYan.Web.Areas.Admin.Controllers;

namespace LiuYan.Web.Areas.Admin.Controllers
{
    public class RoleController : BaseController
    {
        //
        // GET: /Admin/Role/

        public ActionResult Index()
        {
         
            return View();
        }
        public ActionResult RoleAlloat(int id)
        {
            ViewData["id"] = id;
            ViewData["menudata"] = new MenuService().GetAllList(id);

            return View();
        }

        public ActionResult Window(int id)
        {
            ViewData["id"] = id;
            return View();
        }

        public int Del(string ids)
        {
            return new BaseService().Dels(ids, "TB_Roles", false);
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        public string GetList()
        {
            return JsonConvert.SerializeObject(new RoleService().GetList());
        }
        public string GetOneData(int id)
        {
            return JsonConvert.SerializeObject(new BaseService().GetOneData(id, "TB_Roles"));
        }

        public int Edit(FormCollection form)
        {
            TB_Roles entity = new TB_Roles();
            entity.Id = Convert.ToInt32(form["id"]);
            entity.Del = 0;
            entity.IsExit = Convert.ToInt32(form["isexit"]);
            entity.UserId = UserInfo().Id;
            entity.Date = DateTime.Now;
            entity.Remark = form["remark"];
            entity.RoleName = form["name"];
            return new RoleService().Edit(entity);
        }

        public int FpRole(int rid, string menuids)
        {
            return new RoleService().FpRoles(rid, menuids);
        }

    }
}
